package server_demo

import (
	"google.golang.org/grpc"
	"net"
)

// 定义全局变量,方便外部直接注册service
var NarwhalServer *grpc.Server

// 直接默认初始化，为外部直接调用提供方便
func init() {
	// 需要读取固定端口
	NarwhalServer = grpc.NewServer()
}

type AgentServer2 struct {
	addr string
	srvList []srv
}

func (as *AgentServer2) Start() {
	for _,s :=range as.srvList{
		s.Register(NarwhalServer)
	}
	lis,err:=net.Listen("tcp",":8080")
	if err!=nil{
		panic(err)
		return
	}
	NarwhalServer.Serve(lis)
}
